<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  Map<String,String> MapValue=new HashMap<String,String>();
  MapValue=(Map<String,String>)session.getAttribute("MapValue");
  String currentPagestr=(String)session.getAttribute("currentPage");
  String TotalPageCountstr=(String)session.getAttribute("TotalPageCount");
  int currentPage=Integer.parseInt(currentPagestr);
  int TotalPageCount=Integer.parseInt(TotalPageCountstr);
  String CustomerCode=(String)session.getAttribute("CustomerCode");
  String CustomerName=(String)session.getAttribute("CustomerName");  
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>经销商</title>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
       function GetPageCnt(){
         var customercode=document.getElementById("customercode").value;
         var customername=document.getElementById("customername").value;       
         var pagecount=document.getElementById("pageCnt").value;
         var url="CustomerQuery.jsp?CustomerCode="+customercode+"&CustomerName="+customername+"&CurrentPage="+pagecount;
         window.location.href=url;        
       }
       function QueryCustomer(){
         var customercode=document.getElementById("customercode").value;
         var customername=document.getElementById("customername").value;
         var url="CustomerQuery.jsp?CustomerCode="+customercode+"&CustomerName="+customername;
         window.location.href=url;
       }
       function CloseWind(){
         parent.hiddenFrm();
       }
       function choiceRow(){			        
			var stockTable=document.getElementById("customerlist");	                                        	
			var checks=document.getElementsByName("selectOrg");			
			var txt1;	
			var txt2;
			for(var i=checks.length-1;i>=0;i--){
				if(checks[i].checked){
			          var index =checks[i].parentNode.parentNode.rowIndex;
			          var indexc=checks[i].parentNode.cellIndex; 			                                                    
			          txt1 = document.getElementById('customerlist').rows[index].cells[indexc+2].innerHTML;
			          txt2 = document.getElementById('customerlist').rows[index].cells[indexc+1].innerHTML;		                                                                       
				}	
			}		
			parent.setCustomerName(txt1,txt2);
			parent.hiddenFrm();          
       }
    </script>
  </head>
  
  <body>
    <form action="" method="post" name="viewcustomerform">
     <div align="center">
       <table border="1">
          <tr>
            <td>经销商代码</td>
            <%if(CustomerCode==null){ %>
                 <td><input type="text" name="customercode" id="customercode"></input></td>
            <%} else {%>
                 <td><input type="text" name="customercode" id="customercode" value="<%=CustomerCode%>"></input></td>
            <%} %>
            <td>经销商名称</td>
            <%if(CustomerName==null){ %>
                 <td><input type="text" name="customername" id="customername"></input></td>            
            <%}else{%>
                 <td><input type="text" name="customername" id="customername" value="<%=CustomerName%>"></input></td>            
            <%}%>            
            <td></td>
            <td><img src="images/bnt.jpg" style="cursor:hand" onclick="QueryCustomer();"></img></td>
          </tr>
       </table>
       <p></p> 
       <table border="1" id="customerlist">
          <tr>
            <td align="cetner">操  作</td>          
            <td align="center" width="315">经销商代码</td>
            <td align="center" width="315">经销商名称</td>
          </tr>
          <%
            Iterator it=MapValue.entrySet().iterator();
            while(it.hasNext()){
              Map.Entry entry=(Map.Entry)it.next(); 
              Object strkey = entry.getKey(); 
			  Object strvalue = entry.getValue();			           
          %>
          <tr>
            <td align="center"><input id="selectItem" type="radio" name="selectOrg"/></td>          
            <td align="center" width="315"><%=strkey%></td>
            <td align="center" width="315"><%=strvalue%></td>
		  </tr>
          <%}%>
       </table>
        第<%=currentPage%>页 共<%=TotalPageCount%>页  
       <%if(currentPage>1){%>
         <a href="CustomerQuery.jsp?CurrentPage=<%=currentPage-1%>" style="cursor:hand">上一页</a>
       <%}%> 
       <%if(currentPage<TotalPageCount){%>
         <a href="CustomerQuery.jsp?CurrentPage=<%=currentPage+1%>" style="cursor:hand">下一页</a>
       <%}%>
       <input type="text" name="pageCnt" id="pageCnt" size="1"></input><img style="cursor:hand" src="images\go_fy.gif" onclick="GetPageCnt();"></img>
	   <table width="100%" border="0">
	    <tr>
		  <td width="20">&nbsp;</td>
		  <td align="center"><input type="button" value="选择" onclick="choiceRow();"></td>
		  <td width="20">&nbsp;</td>
		  <td align="center"><input type="button" value="退出" onclick="CloseWind();"></td>	
	     </tr>	
	   </table>       
     </div> 
    </form>
  </body>
</html>






































